<?php

namespace app\filters\i18n;

use yii\base\ActionFilter;

class I18nFilter extends ActionFilter {

    //HTTP头
    public $header;

    public function beforeAction($action)
    {
        $locale = \Yii::$app->getRequest()->getHeaders()->get($this->header);
        if($locale){
            \Yii::$app->language = $locale;
        }

        return true;
    }
}